package com.czxy.dem01;

import org.apache.commons.beanutils.BeanUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class Test24 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {

        InputStream is = new FileInputStream(new File("data.properties"));
        Properties properties = new Properties();
        properties.load(is);
        is.close();
        Class<?> aClass = Class.forName("com.czxy.dem01.User");
        Object o = aClass.newInstance();
        for (Object o1 : properties.keySet()) {
            BeanUtils.setProperty(o,o1+"",properties.get(o1));
        }
        System.out.println(o);
    }
}
